<template>
  <div class="main-box">
    <div class="cell-box">
      <div class="title">
        车辆图片
        <span class="car-number">({{ carNumber }}）</span>
      </div>
      <div class="picture" v-viewer="{ movable: false }" v-if="beforeReturnCar.length">
        <div class="img-box" v-for="item in beforeReturnCar" :key="item">
          <img class="img" :src="item" />
        </div>
      </div>
      <div class="picture" v-else>暂无图片</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      carNumber: '',
      beforeReturnCar: []
    }
  },
  created() {
    const { num } = this.$route.params
    this.carNumber = num
    this.fetchData(num)
  },
  methods: {
    fetchData(carNumber) {
      this.$api.vehicle.fetch('queryLastReturnCarImages', { carNumber }).then(res => {
        const beforeReturnCar = []
        res.forEach(val => {
          const { imageUrl } = val
          beforeReturnCar.push(imageUrl)
        })
        this.beforeReturnCar = beforeReturnCar
      })
    }
  }
}
</script>

<style lang="less" scoped>
.main-box {
  margin: 10px 10px;
  .car-number {
    margin-bottom: 5px;
    font-size: 14px;
    color: @content-color;
  }
  .cell-box {
    padding: 20px 20px;
    margin-bottom: 10px;
    background-color: @white;
    border-radius: 10px;
    .title {
      margin-bottom: 10px;
      font-size: @f20;
      color: @label-color;
    }
    .picture {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      min-height: 100px;
      .img-box {
        display: flex;
        align-items: center;
        width: 300px;
        height: 300px;
        padding: 10px 10px;
        margin: 0 10px 10px 0;
        background-color: @border-default;
        border-radius: 10px;
      }
      .img {
        width: 100%;
        max-height: 280px;
        border-radius: 10px;
      }
    }
  }
}
</style>
